import os
import sys
from functools import wraps, update_wrapper

curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)

from utils import LogSys

def run(function):
    @wraps(function)
    def get_fun_name(self, *args, **kwargs):
        LogSys.logInfo('INSTRUMENTATION_STATUS: test=' + function.__name__)
        function(self, *args, **kwargs)
        LogSys.logInfo('INSTRUMENTATION_STATUS:end')
    return get_fun_name


def desc(desc):
    def check_returns(f):
        def new_f(*args, **kwds):
            LogSys.logInfo('INSTRUMENTATION_STATUS: title=' + desc)
            LogSys.logInfo('INSTRUMENTATION_STATUS: api=None')
            result = f(*args, **kwds)
            return result
        update_wrapper(new_f, f)
        return new_f
    return check_returns